import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:inmotion_pro/pages/others/custom_view/setting_items/setting_row.dart';
import 'package:lx_widgets_library/lx_widgets_library.dart';

import '../../../../../l10n/local.dart';
import '../../../../models/account_model_3rd.dart';
import 'controller.dart';

// 绑定第三方账号 View
class Bind3rdAccountView extends BaseGetView<Bind3rdAccountController> {
  Bind3rdAccountView({super.key});

  @override
  String get title => local.bind_social_account;

  @override
  Widget buildBody(BuildContext context) {
    return Container(
      height: double.infinity,
      width: double.infinity,
      color: Colors.black,
      child: Obx(
        () => Column(
          children: [
            ...controller.state.accountList.map((account) {
              return Material(
                color: Colors.black,
                child: SettingRow.arrowWithValue(
                  leading: account.leading,
                  title: account.socialType?.name ?? "",
                  value: account.bindStatus.description,
                  onTap: () {
                    if (account.socialType == null) return;
                    controller.bind3rdAccount(
                        account.bindStatus == Account3rdBindStatus.unbound,
                        account.socialType!);
                  },
                ),
              );
            }).toList(),
            Padding(
              padding: EdgeInsets.all(CONTENT_MARGIN),
              child: LxText(
                local.bind_3rd_account_info_desc,
                color: Colors.white.withOpacity(0.3),
                fontWeightEnum: LxFontWeightEnum.bodySmall,
                lineHeight: 1.5,
              ),
            ),
          ],
        ),
      ),
    );
  }
}
